package com.example.kehoobackend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.kehoobackend.domain.Notice;
import com.example.kehoobackend.persistance.NoticeMapper;
import com.example.kehoobackend.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("noticeService")
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {

//    @Autowired
//    QueryWrapper<Notice> queryWrapper;


    @Override
    public boolean sendNotice(Notice notice) {
        return save(notice);
    }

    @Override
    public boolean deleteNotice(Integer notice_id) {
        return removeById(notice_id);
    }

    @Override
    public List<Notice> getAllNotice(Integer user_id, Integer type) {
        QueryWrapper<Notice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("target_id",user_id);
        if(type == null) return list();
        else {
            queryWrapper.eq("type",type);
            return list(queryWrapper);
        }

    }
}









